package com.nattakute.formatter;

import java.text.ParseException;
import java.util.Locale;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.format.Formatter;
import org.springframework.stereotype.Component;

import com.nattakute.model.Users;
import com.nattakute.service.UserService;


@Component("userFormatter")
public class UserFormatter implements Formatter<Users> {

	@Autowired(required=true)
	@Qualifier("userService")
	private UserService userService;
	
	public String print(Users users, Locale locale) {
		// TODO Auto-generated method stub
		return users.getUserName();
	}

	public Users parse(String string, Locale locale) throws ParseException {
		// TODO Auto-generated method stub
		return userService.findByUserId(Integer.parseInt(string));
	}
	
	
}
